#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
void swap(int* pa, int* pb)
{
	int t = *pa;
	*pa = *pb;
	*pb = t;
}
void LargestTow(int a[], int n, int* pfirst, int* psecond)
{
	for (int i = 0;i < n;i++) {
		for (int j = 0;j < n - 1 - i;j++) {
			if (a[j] < a[j + 1]) {
				swap(&a[j], &a[j + 1]);
			}
		}
	}
	printf("%d %d", a[0], a[1]);
}
int main()
{
	int n = 0;
	scanf("%d", &n);
	int a[1001] = { 0 };
	int i = 0;
	for (i = 0;i < n;i++)
	{
		scanf("%d", &a[i]);
	}
	int* p1 = NULL;
	int* p2 = NULL;
	LargestTow(a, n,p1,p2);
	
	return 0;
}